package com.zh.note.huawei.onehundred.矩阵稀疏扫描;

/**
 * @Author: zhanghuan
 * @date: 2023/9/4 23:01
 * @description: create it
 */

import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int rows = sc.nextInt();
        int cols = sc.nextInt();
        int[][] rowMatrix = new int[rows][cols];
        int[][] colMatrix = new int[cols][rows];

        int rowCount = 0;
        int colHalf = cols / 2;
        //统计每一行连续0的个数
        int[] rowZeroCount = new int[rows];

        for (int i = 0; i < rows; i++) {
            for (int j = 0; j < cols; j++) {
                int input = sc.nextInt();
                rowMatrix[i][j] = input;
                colMatrix[j][i] = input;
                if (input == 0) {
                    rowZeroCount[i]++;
                }
            }
            if (rowZeroCount[i] >= colHalf) {
                rowCount++;
            }
        }

        System.out.println(rowCount);

        int ct = 0;
        colHalf = rows / 2;
        int[] czr = new int[cols];

        for (int i = 0; i < cols; i++) {
            for (int j = 0; j < rows; j++) {
                if (colMatrix[i][j] == 0) {
                    czr[i]++;
                }
            }
            if (czr[i] >= colHalf) {
                ct++;
            }
        }
        System.out.println(ct);
    }
}

